from typing import *


class Solution:
    def minimumLevels(self, possible: List[int]) -> int:
        sm = sum(possible)
        tot = sm - (len(possible) - sm)
        t = 0
        for i in range(len(possible) - 1):
            t += 1 if possible[i] == 1 else -1
            if t > tot - t:
                return i + 1
        return -1
